package org.example.str;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Test01 {

    public static void main(String[] args) {

        String[] source = new String[]{"Hello", "World"};


        //1.生成stream流
        Stream<String> input = Stream.of(source);
        //2.给定单词列表["Hello","World"] ,你想要返回列表 ["H","e","l", "o","W","r","d"]
        List<String> output = input.flatMap(it-> {
            char[] charArr = it.toCharArray();
            List<String> charList = new ArrayList<>();
            for(char chr: charArr){
                if(!charList.contains(chr+"")){
                    charList.add(new StringBuilder().append(chr).toString());
                }
            }
            return charList.stream();
        }).distinct().collect(Collectors.toList());
        System.out.println(output);
    }
}
